<?php

namespace app\admin\model;

use think\Model;

class Notice extends Model
{

    // 表名
    protected $name = 'notice';
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';

	protected function setReadtimeAttr($value)
    {
        return $value && !is_numeric($value) ? strtotime($value) : $value;
    }
	
	protected function setReleasetimeAttr($value)
    {
        return $value && !is_numeric($value) ? strtotime($value) : $value;
    }
	
	public function getReleasetimeAttr($value, $data)
	{
		if($value)
		{
			return date('Y-m-d H:i:s', $value);
		}
	}
	
	public function sender()
    {
        return $this->belongsTo('Admin', 'sender_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
	
	public function receiver()
    {
        return $this->belongsTo('Admin', 'receiver_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
